<?php
require_once 'common.php';
/**
* 升级app接口
*/
class Init extends Common
{
	public function index()
	{
		$res = $this->check();
		switch ($res) {
			case 1:
				return Api::factory()->response(401, '参数不合法');
				break;
			case 2:
				return Api::factory()->response(402, 'app_id不存在');
				break;
			case 3:
				return Api::factory()->response(403, '没有该权限');
				break;
			default:
				break;
		}
		$versionUpgrade = $this->getVersion($this->app['app_id'], 'version_upgrade');
		if ($versionUpgrade) {
			if ($versionUpgrade['type'] && $this->params['version_id'] < $versionUpgrade['version_id']) {
				$versionUpgrade['is_upload'] = $versionUpgrade['type'];
			} else {
				$versionUpgrade['is_upload'] = 0;
			}
			return Api::factory()->response(200, '版本升级信息获取成功', $versionUpgrade);
		} else {
			return Api::factory()->response(400, '版本升级信息获取失败');
		}
	}
}

$init = new Init();
$init->index();